<?php
session_start();
require_once '../header.php';
require_once 'array.php';
function __autoload($className)
	{
    	require_once('../class/' . $className . '.class.php');
	}
session::need_member();
if(!empty($_GET))
{
	
	
	unset($_SESSION["ccid"]);
	unset($_SESSION["moneyplus"]);
	unset($_SESSION["plan"]);
	unset($_SESSION["country"]);
	unset($_SESSION["cc"]);
	$Country=null;
	$condition_later=null;
	$typecc=null;
	$State=null;
	$Dob=null;
	$Ssn=null;
	$ArrReturn=$_GET;
	$Country=$ArrReturn['country'];
	if($Country=='all')
	{
		$Country='us';
	}
	$Country=strtolower($Country);
	$_SESSION["countrybuy"]=$Country;
	$typecc=$ArrReturn['typecc'];
	if(empty($typecc))
	{
		$typefind="4";
	}
	else 
	{
		$typefind=intval($typecc);
	}
	$Plan=$ArrReturn['plan'];
	$State=$ArrReturn['state'];
	$Bincc=intval($ArrReturn['bin']);
	$Dob=$ArrReturn['dob'];
	$Ssn=$ArrReturn['ssn'];
	$VarCheck=$typecc.$Country.$Plan.$State.$Bincc.$Dob.$Ssn;
	$Check=verify::check($VarCheck);
	if($Check==0)
	{
		
		$_SESSION["plan"]=$Plan;
	}
	if(($Check==0)&&($Plan=='our'))
	{
		$PriceBin=1;
		if($Country !=null)
		{
			$GetBinCountry=database::LimitQuery('prices',array(
			'select' => 'bin',
			'condition' => array(
			'country' => $Country
			)
			));
			if(empty($GetBinCountry))
			{
				$PriceBin=1;
			}
			else 
			{
				$PriceBin=$GetBinCountry[0]['bin'];
			}
			$Country="and country='".$Country."' ";
		}
		if($typecc != null)
		{
			$typecc="and typecc ='".$typecc."' ";
		}
		if($State != null)
		{
			$State="and state='".$State."' ";
		}
		if($Dob =='yes')
		{
			$Dob="and dob is not null ";
		}
		if($Dob =='no')
		{
			$Dob="";
		}
		if($Ssn == 'yes')
		{
			$Ssn="and ssn is not null";
		}
		if($Ssn == 'no')
		{
			$Ssn="";
		}
		$MoneyPlus=0;
		if($Bincc != null)
		{
			$lenght=strlen($Bincc);
			$MoneyPlus=($lenght-1)*$PriceBin;
			$condition_later="and ccnumber like '$Bincc%' ";
			
		}
		$_SESSION["moneyplus"]=$MoneyPlus;
		$condition=$Country.$typecc.$State.$condition_later.$Dob.$Ssn;
		$query="select ccid,lastname,ccnumber,exmonth,exyear,city,state,zip,price,country from ccinfo where userid=0 and orderid=0 and site='seller' $condition order by rand() limit 0,40";
		$SearchCC=database::GetQueryResult($query,0,0);	
	}
	else if(($Plan=="codesell")&&($Check==0))
	{
		if($Country=="united states")
		{
			$PriceBin="0.5";
		}
		else
		{
			$PriceBin="1";
		}
		$MoneyPlus=0;
		if($Bincc != null)
		{
			$lenght=strlen($Bincc);
			$MoneyPlus=($lenght-1)*$PriceBin;
			
		}
		$_SESSION["moneyplus"]=$MoneyPlus;
		$ccQuatity=codesell::searchCodeSell($typecc,$Country,$Bincc,$Dob);
		$GetArrPrice=database::LimitQuery('agent_price',array(
		'select' => 'agent_name,typefind,country,agent_price',
		));
		foreach($GetArrPrice as $ShowArrPrice)
		{
			$Key=$ShowArrPrice['country'].$ShowArrPrice['agent_name'];
			$ArrPrice[$Key]=$ShowArrPrice['agent_price'];
		}
		$codeSellKey=$Country."codesell";
		if(empty($ArrPrice[$codeSellKey]))
		{
			$Price="18";
		}
		else
		{
			$Price=$ArrPrice[$codeSellKey];
		}
		$Price=$MoneyPlus+$Price;
		$_SESSION["pricecodesell"]=$Price;
		$_SESSION["typecc"]=$typecc;
		$_SESSION["bincc"]=$Bincc;
		$_SESSION["dob"]=$Dob;
		
		
	}
	else if($Check==0)
	{
		$PriceBin=1;
		$typefind=4;
		if($Country !=null)
		{
			$GetBinCountry=database::LimitQuery('prices',array(
			'select' => 'bin',
			'condition' => array(
			'country' => $Country
			)
			));
			if(empty($GetBinCountry))
			{
				$PriceBin=1;
			}
			else 
			{
				$PriceBin=$GetBinCountry[0]['bin'];
			}
			
		}
		else
		{
			$PriceBin=1;
		}
		$GetArrPrice=database::LimitQuery('agent_price',array(
		'select' => 'agent_name,typefind,country,agent_price',
		'condition' => array(
		'agent_name' => $Plan,
		'typefind' => $typefind,
		'country' => $Country
		)
		));
		
		if(empty($GetArrPrice))
		{
			$getPrice=database::LimitQuery('agent_price',array(
			'select' => 'agent_price',
			'condition' => array(
			'agent_name' => $Plan,
			'country' => 'all'
			)
			));
			$priceTemp=$getPrice[0]['agent_price'];
		}
		else
		{
			$priceTemp=$GetArrPrice[0]['agent_price'];
		}
		$MoneyPlus=0;
		$lenght=strlen($Bincc);
		$MoneyPlus=($lenght-1)*$PriceBin;
		$_SESSION["moneyplus"]=$MoneyPlus;
		$price=$priceTemp+$MoneyPlus;
		if($Plan=='ltd')
		{
			$SearchCC=ltdcc::SearchCC($Country, $typecc, $Bincc, $State,$price);
		}
		else if($Plan=='vmarket')
		{
			$SearchCC=vmarket::searchCcVmarket($Country, $Bincc, $typecc, $Dob, $Ssn, $price);
		}
		else if($Plan=="ghcc")
		{
			$SearchCC=ghcc::searchCcGhcc($Country, $typecc, $Bincc,$price);
		}
		else if($Plan=="cardcf")
		{
			$SearchCC=cardcafe::searchCcCardCafe($Country,$Bincc, $typecc, $price);
		}
		else
		{
			$SearchCC=buycc::SearchCC($Country,$Bincc, $typecc, $price, $Plan);
		}
	}
	require_once '../html/showccinfo.php';
	
	
}
else
{
	require_once '../html/buycc.php';
}

?>
<div id="freshcvvccinfo" ></div>